home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0097_Image to File.pas < prev    next >
Pascal/Delphi Source File  |  1994-05-26  |  1KB  |  48 lines

  1. {
  2. S> Hi all.. I need some help.. I'm using GetImage to grab a portion
  3. AS> of the graphics screen - so I can use PutImaget to "Paste" it on
  4. AS> the screen later.  My question is : Can this GetImage be saved to
  5. AS> a file & loaded later.. If so how do I save and load it?  I would
  6. AS> appreciate any help you can give me ... Angel Sanchez.
  7.  
  8. It sure can.  Take a look at this code:
  9.  
  10. To Save: }
  11.  
  12. program SaveImage;
  13.  
  14. var
  15.   upx, lefty, downx, righty: word;
  16.   ScreenCapSize : longint;
  17.   ScreenLoc : pointer;
  18.   CapFile : file;
  19.  
  20. ScreenCapSize := ImageSize(upx, lefty, downx, righty);
  21. GetMem(ScreenLoc, ScreenCapSize);
  22. GetImage(upx, lefty, downX, rightY, ScreenLoc^);
  23. Assign(CapFile, 'FILENAME.FIL');
  24. Rewrite(CapFile, ImageSize(0,0,60,60));
  25. BlockWrite(CapFile, ScreenLoc^, ScreenCapSize);
  26. Close(CapFile);
  27. end.
  28.  
  29. program LoadImage;
  30.  
  31. var
  32.   X, Y: word;
  33.   ScreenCapSize : longint;
  34.   ScreenLoc : pointer;
  35.   CapFile : file;
  36.  
  37. begin
  38. ScreenCapSize := {Original Size of capture pic}
  39. GetMem(ScreenLoc, ScreenCapSize);
  40. Assign(CapFile, 'FILENAME.FIL');
  41. Reset(CapFile, ScreenCapSize);
  42. Seek(CapFile, 1 {Or whichever image to read});
  43. BlockRead(CapFile, ScreenLoc^, ScreenCapSize);
  44. Close(CapFile);
  45. PutImage(X, Y, ScreenLoc^);
  46. end.
  47.  
  48.